runOnStartup(async runtime => {
    window.addEventListener("shopTick", (e) => {
        ReadyShop_ItemBoxItemChoose.ItemChooseShowInformation()
    })
    window.addEventListener("shopInit", (e) => {
        ReadyShop_ItemBoxItemChoose.ItemChoose()
    })
});
globalThis.ReadyShop_ItemBoxItemChoose = {
    ItemChoose: function () {
        ReadyShop_ItemBoxItemChoose.chooseItem = null
        ReadyShop_ItemBoxItemChoose.ChooseItemBox = null
        window.addEventListener("ClickShopItem", (e) => {
            var Item = e.detail[0]
            for (let itemBox of runtime.objects.UIitemBox.instances()) {
                itemBox.setAnimation("Normal")
                if (itemBox.testOverlap(Item)) {
                    ReadyShop_ItemBoxItemChoose.chooseItem = Item
                    ReadyShop_ItemBoxItemChoose.ChooseItemBox = itemBox
                    //console.log(ReadyShop_ItemBoxItemChoose.ChooseItemBox)
                    itemBox.setAnimation("Choose")
                    
                    
                    //itemBox.destroy()
                }
            }
        })
    },
    ItemChooseShowInformation: function () {
        var getChooseItem = ReadyShop_ItemBoxItemChoose.chooseItem
        var InformaitionTextInstance = runtime.objects.ItemInfrrmationText?.getFirstInstance()
        if (getChooseItem == null) {
            InformaitionTextInstance.text = cc_Game.Game_GameStringBranch.item_default_infor[cc_Game.Game_GameStringBranch.Languge]
            return
        }
        var ItemPrice = getChooseItem.instVars.Price
        const  lan =cc_Game.Game_GameStringBranch.Languge
        const  trans =cc_Game.Game_GameStringBranch
        InformaitionTextInstance.text = getChooseItem.instVars[trans.Languge+"_infor"] + "\n \n[size=30][color=yellow]"+trans.price[lan]+":" +ItemPrice
    }
}
export default ReadyShop_ItemBoxItemChoose